package com.magenta.maxoptra.gis;

import static com.magenta.maxoptra.gis.GisParameter.*;
import static com.magenta.maxoptra.gis.MapProviderType.yournavigation;

/**
 * @author Zaur Muhametgaleev
 * @version 12/5/11 4:23 PM
 * @see "jira task MRS-4127: Add support of YourNavigation.Org routing provider"
 * @since Maxoptra 3 (GT)
 */
public enum YournavigationAttribute implements GISAccountProperty {
//    UseProvider(GisParameter.use_map_provider, MapProviderType.yournavigation, GISFieldType.BOOLEAN, "true", true, 0L, true, false),
    YournavigationUrl(base_url, yournavigation, GISFieldType.TEXT,
            "http://www.yournavigation.org/api/dev/route.php?flat={0}&flon={1}&tlat={2}&tlon={3}&fast={4}",
            false, 1L, true, false),
    YournavigationUseShortestRoute(use_shortest_route, yournavigation, GISFieldType.BOOLEAN, "true", false, 2L, true, false),
    YournavigationEnableLog(enableLogging, yournavigation, GISFieldType.BOOLEAN, "false", false, 3L, true, false),
    YournavigationEnableCache(enableCache, yournavigation, GISFieldType.BOOLEAN, "true", true, 7L, true, false),
    YournavigationCacheStorageTime(cacheStorageTime, yournavigation, GISFieldType.INTEGER, "30", true, 11L, true, false),
    YournavigationUseMultiplePointsRouting(useMultiplePointsRouting, yournavigation, GISFieldType.BOOLEAN, "true", false, 4L, true, true);

    private String name;
    private String label;
    private String tab = "GIS";
    private Long order;
    private GISFieldType type;
    private String defaultValue;
    private boolean required;
    private String groupName;
    private boolean important = true;
    private boolean readOnly = false;

    @Override
    public String getName() {
        return name;
    }

    @Override
    public GISFieldType getType() {
        return type;
    }

    @Override
    public String getLabel() {
        return label;
    }

    @Override
    public Long getOrder() {
        return order;
    }

    @Override
    public Boolean getMandatory() {
        return required;
    }

    @Override
    public String getGroup() {
        return groupName;
    }

    @Override
    public String getDefaultValue() {
        return defaultValue;
    }

    @Override
    public boolean isImportant() {
        return important;
    }

    public String getTab() {
        return tab;
    }

    private YournavigationAttribute(String name, String label, GISFieldType type, String defaultValue,
                                    boolean required, String groupName, Long order, boolean important, boolean readOnly
    ) {
        this.name = name;
        this.label = label;
        this.type = type;
        this.defaultValue = defaultValue;
        this.groupName = groupName;
        this.required = required;
        this.order = order;
        this.important = important;
        this.readOnly = readOnly;
    }

    private YournavigationAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                                    String defaultValue, boolean required, Long order, boolean important, boolean readOnly) {
        this(parameter.withProvider(providerType.name()),
                parameter.getLabel(),
                type,
                defaultValue,
                required,
                providerType.getLabel(),
                order, important, readOnly);
    }

    public boolean isReadOnly() {
        return readOnly;
    }

}
